package com.muyu.day3zy.controller;

import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.domain.AjaxResult;
import com.muyu.day3zy.domain.BrandInfo;
import com.muyu.day3zy.domain.ProductInfo;
import com.muyu.day3zy.domain.SkuInfo;
import com.muyu.day3zy.domain.vo.PromotionInfoVo;
import com.muyu.day3zy.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName GoodsController
 * @Description 描述
 * @Author ShiYu.Cui
 * @Date 2024/3/24 11:23
 */
@RestController
public class GoodsController extends BaseController {
    @Autowired
    private GoodsService goodsService;

    @PostMapping("/findBrand")
    public List<BrandInfo> list(){
        List<BrandInfo> list=goodsService.list();
        return list;
    }

    /**
     * 添加商品信息
     * @param productInfo
     * @return
     */
    @PostMapping("/addProductInfo")
    public AjaxResult addProductInfo(@RequestBody ProductInfo productInfo){
        goodsService.addProductInfo(productInfo);
        return AjaxResult.success();
    }

    /**
     * 添加商品促销
     * @param promotionInfoVo
     * @return
     */
    @PostMapping("/addPromotionInfo")
    public AjaxResult addPromotionInfo(@RequestBody PromotionInfoVo promotionInfoVo){
        goodsService.addPromotionInfo(promotionInfoVo);
        return AjaxResult.success();
    }

    @PostMapping("addSkuInfo")
    public AjaxResult addSkuInfo(@RequestBody SkuInfo skuInfo){
        goodsService.addSkuInfo(skuInfo);
        return AjaxResult.success();
    }

}
